/*
 * Report Run Page for Report Module JS
 * This creates the admin GUI Run Page for the Reports Module
 *
 * JSLint.com Check:
 */

RM.Pages.Functions.Reports_Run_Show = function(id){

    new Ext.Window({
        id: 'rm_reports_window',
        title: RM.Translate.Admin.Reports.Run.Title,
        renderTo: "content-panel",
        layout: 'fit',
        minWidth: 800,
        minHeight: 600,
        maximizable: true,
        modal: true,
        plain: true,
        autoDestroy: true,
        items: [
           new Ext.Panel({
                id: 'rm_reports_main_panel',
                activeItem: 0,
                layout: 'card',
                bodyBorder : false,
                autoScroll: true,
                buttons: [{
                    text: RM.Translate.Admin.Reports.Run.Print,
                    id: 'rm_reports_run_button_print',
                    handler: function(){
                        Ext.ux.Printer.print(Ext.getCmp("rm_reports_main_panel"));
                    }
                }
                ],
                autoLoad: {
                    url: RM.Common.AssembleURL({
                        controller : 'Reports',
                        action: 'showreport',
                        parameters: [{
                            name: 'id',
                            value: id
                        }]
                    }),
                    scripts: true
                }
            })
        ],
        listeners: {
            'beforehide': function(){
                RM.Pages.Reports_Window_Mask.hide();
                return true;
            }
        }
    });

    Ext.getCmp('rm_reports_window').show();
    Ext.getCmp('rm_reports_window').setWidth(800);
    Ext.getCmp('rm_reports_window').setHeight(600);
    Ext.getCmp('rm_reports_window').setPosition(50,50);
    RM.Pages.Reports_Window_Mask.hide();
};


RM.Pages.Functions.Reports_RunJson_Request = function(id){

    RM.Pages.Reports_Window_Mask = new Ext.LoadMask('content-panel', {msg: RM.Translate.Common.PleaseWait});
    RM.Pages.Reports_Window_Mask.show();

    RM.Pages.Functions.Reports_Run_Show(id);

};